#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
const int N = 1e6 + 5;

void solve() {
    int n;
    cin >> n;
    vector<ll> a(n + 1), b(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        b[i] = to_string(a[i]).size() & 1;
        a[i] %= 11;
    }
    vector<vector<ll>> cnt(2, vector<ll>(11));
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += cnt[1][a[i]];
        ans += cnt[0][(11 - a[i]) % 11];
        if (b[i]) {
            ans += cnt[0][a[i]] + cnt[1][a[i]];
        } else {
            ans += cnt[0][(11 - a[i]) % 11] + cnt[1][(11 - a[i]) % 11];
        }
        cnt[b[i]][a[i]]++;
    }
    cout << ans << endl;
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();

    return 0;
}